﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Factories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XNA_2DFramwork;

namespace City_War_Game
{
    class Building : VisualObject
    {
        private Rectangle r;
        public Building(Game game, int width, int height, Vector2 position, string filename, GraphicsDevice gd, PhysicsSimulator physicsSimulator)
            : base(game)
        {
            this.Position = position;
            PhysicsSimulator = physicsSimulator;
            Texture = Game.Content.Load<Texture2D>(filename);
            
            Width = width;
            Height = height;
            Origin = new Vector2(Width / 2f, Height / 2f);
            SpriteBatch = new SpriteBatch(gd);
            Body = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, Width, Height, 1);
            Body.Position = position;
            r = new Rectangle(0, 0, Width, Height);
            Geom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, Body, Width, Height);
            Geom.FrictionCoefficient = 1;
        }

        public override void Draw()
        {
            SpriteBatch.Begin();
            SpriteBatch.Draw(Texture, Body.Position, r, Color.White, Body.Rotation, Origin, 1f,
                SpriteEffects.None, 0f);
            SpriteBatch.End();
        }

        public override void Update()
        {            
        }
    }
}
